package com.school.movie.service.imp;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.school.movie.business.mobile.model.pojo.VideoComment;
import com.school.movie.business.web.model.vo.ForumVo;
import com.school.movie.dao.VideoCommentMapper;
import com.school.movie.service.VideoCommentService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (VideoComment)表服务实现类
 *
 * @author makejava
 * @since 2021-01-29 13:00:12
 */
@Service("videoCommentService")
public class VideoCommentServiceImpl extends ServiceImpl<VideoCommentMapper,VideoComment> implements VideoCommentService {
    @Resource
    private VideoCommentMapper videoCommentMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public VideoComment queryById(String id) {
        return this.videoCommentMapper.queryById(Long.valueOf(id));
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<VideoComment> queryAllByLimit(int offset, int limit) {
        return this.videoCommentMapper.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param videoComment 实例对象
     * @return 实例对象
     */
    @Override
    public VideoComment insert(VideoComment videoComment) {
        this.videoCommentMapper.insert(videoComment);
        return videoComment;
    }

    /**
     * 修改数据
     *
     * @param videoComment 实例对象
     * @return 实例对象
     */
    @Override
    public VideoComment update(VideoComment videoComment) {
        this.videoCommentMapper.update(videoComment);
        return this.queryById(String.valueOf(videoComment.getForumId()));
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(String id) {
        return this.videoCommentMapper.deleteById(id) > 0;
    }

    @Override
    public List<ForumVo> getReplies(Integer forumId) {
        return videoCommentMapper.getReplies(forumId);
    }

    @Override
    public List<ForumVo> getForumList(Long vid) {
        return videoCommentMapper.getForumList(vid);
    }


}